# 登录邮箱   wqc1024528@163.com
# 原始ID   gh_80f544c594a4
# 开发者ID(AppID)   wxadc78b6c3cb8ae7e
# AppSecret   80d45b57951a9f81e369674046641398
#
#
# {"access_token":"75_Ik6OEpEWiacYeBraaY9rIaNLdKMtZsrKnkWb24aYG7_P1hLdaIttrcdWr46ViZNqyg0Jzi43dM6oXI0fyMcpf9FBMQaoxyTB1e1yoakOTJGPxIUqscmslckKYxQQIXgAHAWOD","expires_in":7200}

# 参考文献:https://www.bilibili.com/read/cv28706223/
import json

import time
import requests

from ttzScrapyProject.constants import UrlConstant
from ttzScrapyProject.utils import MumberUtils
from ttzScrapyProject.utils.DateUtils import getDate

"""
    "莫葙依"
    "Everything is possible丶"
"""
def send_message(userNoticeList, message):
    sendUrl = f"{UrlConstant.WX_REBOT_URL}webhook/msg"
    for toUser in userNoticeList.split("；"):
        data = {
            "to": toUser,
            "type": "text",
            "content": message
        }
        headers = {
            "Content-Type": "application/json"
        }
        r = requests.post(sendUrl, data=json.dumps(data), headers=headers)
        jsonText = json.loads(r.text)

    return jsonText["success"]


def getStartText(phone, curCobin, target,todayWin,date,model):
    return f"start==================\n" \
           f"当前日期{date}\n" \
           f"当前手机号{phone}\n" \
           f"模式{model}\n" \
           f"状态:已启动\n" \
           f"当前账户余额{curCobin}\n" \
           f"目标余额{target}\n" \
           f"今日目标{todayWin}\n" \
           f"预定到达目标后{MumberUtils.strToInt(target)+ MumberUtils.strToInt(curCobin)}\n"


def getStopText(phone, curCobin,date,model):
    return f"end==================\n" \
           f"当前日期{date}\n" \
           f"当前手机号{phone}\n" \
           f"模式{model}\n" \
           f"状态:已停止\n" \
           f"当前账户余额{curCobin}\n"


if __name__ == '__main__':
    phone = "18340057070"
    curCobin = "123213213"
    target = "500000"
    # toUser = "莫葙依"
    # toUser = "Everything is possible丶；莫葙依"
    toUser = "Everything is possible丶"
    for i in toUser.split("；"):
        print(i)
        startText = getStartText(phone, curCobin, target,getDate())
        send_message(i, startText)
        stopText = getStopText(phone, curCobin,getDate())
        send_message(i, stopText)